<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            background-color: #000;
        }
        li {
            list-style: none;
        }
        .box {
            width: 642px;
            height: 432px;
            background-color: #000;
            margin: 100px auto;
            overflow: hidden;
        }
        .box ul {
            overflow: hidden;
            border: 10px solid black;
            margin: 1px;
        }
        .box ul li {
            width: 200px;
            height: 200px;
            border-bottom : 10px solid black;
            border-right: 10px solid black;
            float: left;
            
        }
        .box ul li img {
            width: 200px;
            height: 200px;
            
        }
        .box ul li:nth-child(3n) {
            border-right : none;
        }
        .box ul li:nth-child(n+4) {
            border-bottom : none;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li><img src="images/01.jpg" alt=""></li>
            <li><img src="images/02.jpg" alt=""></li>
            <li><img src="images/03.jpg" alt=""></li>
            <li><img src="images/04.jpg" alt=""></li>
            <li><img src="images/05.jpg" alt=""></li>
            <li><img src="images/06.jpg" alt=""></li>
        </ul>
    </div>
</body>
<script>
    //获取元素
    var liList = document.querySelectorAll('.box li');
    var box = document.querySelector('.box');
    var ul = document.querySelector('ul');

    //注册事件
    for(var i = 0; i < liList.length; i++) {
        liList[i].onmouseenter = liMouseenter
    }
    function liMouseenter(){
        for(var i = 0; i < liList.length; i++){
            if(this == liList[i]){
                this.style.opacity = 1
            }else {
                liList[i].style.opacity = 0.5
            }
        }
    }
    box.onmouseleave = function(){
        for(var i = 0; i < liList.length; i++) {
            liList[i].style.opacity = 1;
        }
    }

</script>
<script src='../jquery-1.12.4.js'></script>
<script>
    // $(function(){
    //     $('.box li').on('mouseenter',function(){
    //         $(this).css('opacity',1).siblings().css('opacity',0.5);
    //     })
    //     $('.box').on('mouseleave',function(){
    //         $('.box li').css('opacity',1);
    //     })
    // })
</script>
</html>